home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.3 / IEEE / src / bench / savage.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  2.6 KB  |  86 lines

  1. /*---------------------------- Start C Source ----------------------------*/
  2.  
  3. /******************************/
  4. /*          Savage.c          */
  5. /*       Amiga Version        */
  6. /******************************/
  7.  
  8. /*********************************************************************/
  9. /* Savage Tests the speed at which a system can do a SUBSET of the   */
  10. /* double precision trigonometric and transcendental functions.      */
  11. /*********************************************************************/
  12.  
  13. #include <stdio.h>
  14. #include <math.h>
  15. double atan(),acos(),asin(),tan(),cos(),sin();
  16. double log(),exp(),sqrt();
  17.  
  18. /*#define fudge 10*/        /* use this for slow machines */
  19. #define fudge 1            /* used for fast machines */
  20.  
  21. main()
  22. {
  23.    double a,e;
  24.    int i,iu,loops;
  25.  
  26.    long  starttime,benchtime,nulltime;  /* Timing Variables and function. */
  27.    long  stoptime, timeticks();         /* timeticks() specific to Amiga. */
  28.                                         /* Replace with your system       */
  29.                                         /* function.                      */
  30.  
  31.    loops = 25000 / fudge;                        /* Number of loops. Slow  */
  32.                                                 /* machines use 2500.     */
  33.                                                 /* Faster machines 25,000.*/
  34.                                                 /* All results referenced */
  35.                                                 /* to 25,000 loop.        */
  36.  
  37.    printf("\n   Savage Benchmark\n");
  38.  
  39.    starttime = timeticks();                     /* Determine timer delay  */
  40.    stoptime  = timeticks();
  41.    nulltime  = stoptime  - starttime;
  42.  
  43.    starttime = timeticks();                        /* Start timer. */
  44.  
  45.    iu= loops - 1;
  46.    a = 1.0;
  47.  
  48.       for ( i = 1 ; i<= iu ; i++)
  49.       {
  50.       a = tan(atan(exp(log(sqrt(a*a))))) + 1.0;
  51.       }
  52.  
  53.    stoptime  = timeticks();                        /* Stop timing . */
  54.    benchtime = stoptime - starttime - nulltime;
  55.  
  56.    e = a - (double)loops;
  57.    printf("   Benchtime (50 * sec ) = %ld\n",benchtime);
  58.    printf("   loops = %d\n",loops);
  59.    printf("   a     = %24.16e\n",a);
  60.    printf("   Error = %24.16e\n\n",e);
  61.  
  62. }
  63.  
  64.  
  65. /*******************************************************/
  66. /* Timer returns time ticks (50 * sec) since midnight. */
  67. /* Amiga specific, Replace with your own routine.      */
  68. /*******************************************************/
  69.  
  70. long  timeticks()
  71. {
  72.    struct   tt {
  73.       long  days;
  74.       long  minutes;
  75.       long  ticks;
  76.    } tt;
  77.    DateStamp(&tt);
  78.  
  79.    return (tt.ticks + (tt.minutes * 60L * 50L));
  80. }
  81.  
  82. /*-------------------------- End of C Source -----------------------------*/
  83.  
  84.  
  85.  
  86.